From: Gianni Tedesco Date: Mon, 16 Aug 2010 12:39:19 +0000 (+0100) Subject: tools/libxl: remove libxl_free() since there are no more callers X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~11638 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks://%22/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22?a=commitdiff_plain;h=8eb8ac72924e430b89497995be61ccb2a2402919;p=xen.git tools/libxl: remove libxl_free() since there are no more callers libxl_free() allows allocated memory to be explicitly free'd from a libxl_gc. Every previous use of this function has now been made redundant and therefore has been removed. We can safely kill it and amend the policy accordingly. Signed-off-by: Gianni Tedesco Signed-off-by: Ian Jackson --- diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index 2d289735d8..fe117377c5 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -117,10 +117,9 @@ * and an internal wrapper adds the relevant pointers to the gc. * The latter method is preferred for obvious performance reasons. * - * No temporary objects allocated from the pool should be explicitly freed. - * Calling libxl_free_all() before returning from a public functions will do - * this. The upshot of this is that almost all calls to libxl_free() are - * erroneous. + * No temporary objects allocated from the pool may be explicitly freed. + * Therefore public functions which initialize a libxl_gc MUST call + * libxl_free_all() before returning. */ #ifndef LIBXL_H #define LIBXL_H diff --git a/tools/libxl/libxl_internal.c b/tools/libxl/libxl_internal.c index 2d5ad9a033..5eb27a6f4d 100644 --- a/tools/libxl/libxl_internal.c +++ b/tools/libxl/libxl_internal.c @@ -59,25 +59,6 @@ int libxl_ptr_add(libxl_gc *gc, void *ptr) return 0; } -void libxl_free(libxl_gc *gc, void *ptr) -{ - int i; - - if (!ptr) - return; - - /* remove the pointer from the tracked ptrs */ - for (i = 0; i < gc->alloc_maxsize; i++) { - if (gc->alloc_ptrs[i] == ptr) { - gc->alloc_ptrs[i] = NULL; - free(ptr); - return; - } - } - /* haven't find the pointer, really bad */ - abort(); -} - void libxl_free_all(libxl_gc *gc) { void *ptr; diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index fecb009e7c..dc6e1c8e8f 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -129,7 +129,6 @@ static inline libxl_ctx *libxl_gc_owner(libxl_gc *gc) /* memory allocation tracking/helpers */ _hidden int libxl_ptr_add(libxl_gc *gc, void *ptr); -_hidden void libxl_free(libxl_gc *gc, void *ptr); _hidden void libxl_free_all(libxl_gc *gc); _hidden void *libxl_zalloc(libxl_gc *gc, int bytes); _hidden void *libxl_calloc(libxl_gc *gc, size_t nmemb, size_t size);